<?php

namespace backend\modules\home\models;

use Yii;

/**
 * This is the model class for table "mh_collection".
 *
 * @property int $id
 * @property int $uid
 * @property int $book_code
 * @property int $create_at
 */
class Collection extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'mh_collection';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['uid', 'book_code'], 'required'],
            [['uid', 'book_code', 'create_at'], 'integer'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'uid' => 'Uid',
            'book_code' => 'Book Code',
            'create_at' => 'Create At',
        ];
    }

    public function getBookInfo(){
        return $this->hasOne(Booklist::className(), ['number' => 'book_code'])->asArray();
    }
}
